package me.aartikov.alligator.commands;


import me.aartikov.alligator.Screen;
import me.aartikov.alligator.animations.AnimationData;
import me.aartikov.alligator.destinations.AbilityDestination;
import me.aartikov.alligator.destinations.DialogFragmentDestination;
import me.aartikov.alligator.destinations.FragmentDestination;
import me.aartikov.alligator.exceptions.NavigationException;
import me.aartikov.alligator.navigators.AbilityNavigator;
import me.aartikov.alligator.navigators.DialogFragmentNavigator;
import me.aartikov.alligator.navigators.FragmentNavigator;

/**
 * Command implementation for {@code replace} method of {@link OhosNavigator}.
 */
public class ReplaceCommand extends BaseCommand {
    private Screen mScreen;

    private AnimationData mAnimationData;

    public ReplaceCommand(Screen screen, AnimationData animationData) {
        super(screen.getClass());
        mScreen = screen;
        mAnimationData = animationData;
    }

    @Override
    protected boolean executeForActivity(AbilityDestination destination, AbilityNavigator activityNavigator) throws NavigationException {
        return activityNavigator.replace(mScreen, destination, mAnimationData);
    }

    @Override
    protected boolean executeForFragment(FragmentDestination destination, FragmentNavigator fragmentNavigator) throws NavigationException {
        return fragmentNavigator.replace(mScreen, destination, mAnimationData);
    }

    @Override
    protected void executeForDialogFragment(DialogFragmentDestination destination, DialogFragmentNavigator dialogFragmentNavigator) throws NavigationException {
        dialogFragmentNavigator.replace(mScreen, destination, mAnimationData);
    }
}